package org.xu.logic;

import com.core.utils.UUIDGenerator;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.xu.entity.AdapterCarInfoEntity;
import org.xu.entity.WorkFlowLogEntity;
import org.xu.service.AdapterCarInfoService;

/**
 * @author liuxiaoxu
 */
@Slf4j
@Service
public class AdapterCarInfoLogicImpl implements AdapterCarInfoLogic{

    @Autowired
    private AdapterCarInfoService carInfoService;
    @Autowired
    private WorkFlowLogic workFlowLogic;
    @Override
    @Transactional
    public int update() {

        String applyNo = UUIDGenerator.generate().substring(15);
        log.info("applyNo==== :{}",applyNo);
        AdapterCarInfoEntity record = new AdapterCarInfoEntity();
        record.setId("0000211668763502556");
        record.setApplyNo(applyNo);
        carInfoService.updateByPrimaryKeySelective(record);
        try {
            // 有事务注解，抛异常
             workFlowLogic.logTest();
            //   this.log();
        }catch (Exception e){
            log.info("===",e);
        }
        int b = 1 / 0;
        System.out.printf("111111");
        return 1;
    }

    @Transactional
    public void log(){
        WorkFlowLogEntity record = new WorkFlowLogEntity();
        record.setId(UUIDGenerator.generate());
        record.setApplyNo("1234");
        record.setRemark("测试事务");
        workFlowLogic.insert(record);
        int b = 1 / 0;
    }

}
